﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_CM_GetClientInfo]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_CM_GetClientInfo];
GO
CREATE PROCEDURE [dbo].[sproc_CM_GetClientInfo]
@clientid int

AS

    IF(@clientid=0)
        SELECT NAME,ID,ShortName,ContactTimes,UDS_CM_ClientInfo.Birthday,UpdateTime,Staff_Name AS Linkman,Linkman_Telephone,Fee,BargainPrognosis,SellPhase FROM UDS_CM_ClientInfo LEFT JOIN UDS_Staff
        ON  UDS_CM_ClientInfo.ChiefLinkmanID=UDS_Staff.Staff_ID
    ELSE
        SELECT NAME,ID,ShortName,ContactTimes,UDS_CM_ClientInfo.Birthday,UpdateTime,Staff_Name AS Linkman,Linkman_Telephone,Fee,BargainPrognosis,SellPhase FROM UDS_CM_ClientInfo LEFT JOIN UDS_Staff
        ON UDS_CM_ClientInfo.ChiefLinkmanID=UDS_Staff.Staff_ID
        WHERE id=@clientid